package java8.lambda;

import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * @program: util
 * @description: 测试构造函数引用
 * @author: zhouliangliang
 * @create: 2019-08-27 10:20
 **/
public class ConstructorReference {

    public void test() {
        Supplier<Apple> appleType1 = Apple::new;
        Apple apple1 = appleType1.get();
        System.out.println(apple1);

        Function<String, Apple> appleType2= Apple::new;
        Apple apple2 = appleType2.apply("yellow");
        System.out.println(apple2);

        BiFunction<String, Integer, Apple> appleType3 = Apple::new;
        Apple apple3 = appleType3.apply("green", 150);
        System.out.println(apple3);

        TriFunction<String, Integer, String, Apple> appleType4 = Apple::new;
        Apple apple4 = appleType4.apply("blue", 200, "USA");
        System.out.println(apple4);
    }

    public static void main(String[] args) {
        new ConstructorReference().test();
    }
}
